package com.zlt.healthpass.controller;

import com.zlt.healthpass.bean.NucleicAcidTestSub;
import com.zlt.healthpass.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @program: HealthPass
 * @description: 医院接口
 * @author: Mr.abel(ShiJiaYi)
 * @create: 2022-07-15 16:12
 **/
@Api(tags = "医院接口")
@Controller
public class HospitalController {
    //和业务逻辑层进行关联
    @Autowired
    private IUserInfoService iis;

    @ApiOperation(value = "提交核酸检测结果接口", notes = "传入用户id 检测时间 采样时间 医院地址 检测结果")
    @PostMapping("/postNATR")
    @ResponseBody
    public int postNATR(@RequestBody NucleicAcidTestSub nats){
        //把创建时间改为当前系统时间
        nats.setCreateTime(new Date());
        int uninfected = iis.uninfected(nats);
        //被感染了
        if(nats.getResult() == 1){
            iis.infected(nats);
        }
        return uninfected;
    }
}
